<!DOCTYPE html>
<html lang="en">

<!-- Mirrored from uxliner.com/adminkit/demo/main/ltr/index.html by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 14 May 2021 17:30:44 GMT -->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>${title} - 机票预订系统</title>
<#include "../header.ftl">
<!-- Left side column. contains the logo and sidebar -->
<#include "../nav.ftl">
  
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper"> 
    <!-- Content Header (Page header) -->
    <div class="content-header sty-one">
      <h1>${title}</h1>
      <ol class="breadcrumb">
        <li><a href="/admin/index.html">主页</a></li>
        <li><i class="fa fa-angle-right"></i> ${title}</li>
      </ol>
    </div>
    
    <!-- Main content -->
    <div class="content">
      <div class="card">
      <div class="card-body">
      <form action="do_add_flight.html" id="submitForm" method="post" class="search-form">
        <div class="row">
          <div class="col-lg-2">
            <fieldset class="form-group">
              <label>航班号</label>
              <input class="form-control" id="flightNumber" name="flightNumber" type="text">
            </fieldset>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-2">
            <fieldset class="form-group">
              <label>航班公司</label>
              <select class="custom-select form-control" id="flightCompany" name="flightCompany">
              	<option value="南方航空">南方航空</option>
              	<option value="东方航空">东方航空</option>
              	<option value="国泰航空">国泰航空</option>
              	<option value="中国航空">中国航空</option>
              	<option value="春秋航空">春秋航空</option>
              </select>
            </fieldset>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-2">
            <fieldset class="form-group">
              <label>机型</label>
              <select class="custom-select form-control" id="flightModel" name="flightModel">
              	<option value="波音737">波音737</option>
              	<option value="波音747">波音747</option>
              	<option value="波音757">波音757</option>
              	<option value="空客A320">空客A320</option>
              	<option value="空客A318">空客A318</option>
              	<option value="空客A319">空客A319</option>
              </select>
            </fieldset>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-2">
            <fieldset class="form-group">
              <label>价格</label>
              <input class="form-control" id="price" name="price" type="text">
            </fieldset>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-2">
            <fieldset class="form-group">
              <label>出发地</label>
              <select class="custom-select form-control" id="departurePlace" name="departurePlace">
              	<option value="广州">广州</option>
              	<option value="深圳">深圳</option>
              	<option value="北京">北京</option>
              	<option value="上海">上海</option>
              	<option value="天津">天津</option>
              	<option value="成都">成都</option>
              	<option value="武汉">武汉</option>
              	<option value="重庆">重庆</option>
              	<option value="南宁">南宁</option>
              	<option value="拉萨">拉萨</option>
              	<option value="贵阳">贵阳</option>
              	<option value="石家庄">石家庄</option>
              </select>
            </fieldset>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-2">
            <fieldset class="form-group">
              <label>到达地</label>
              <select class="custom-select form-control" id="arrivalPlace" name="arrivalPlace">
              	<option value="广州">广州</option>
              	<option value="深圳">深圳</option>
              	<option value="北京">北京</option>
              	<option value="上海">上海</option>
              	<option value="天津">天津</option>
              	<option value="成都">成都</option>
              	<option value="武汉">武汉</option>
              	<option value="重庆">重庆</option>
              	<option value="南宁">南宁</option>
              	<option value="拉萨">拉萨</option>
              	<option value="贵阳">贵阳</option>
              	<option value="石家庄">石家庄</option>
              </select>
            </fieldset>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-2">
            <fieldset class="form-group">
              <label>出发机场</label>
              <input class="form-control" id="departureAirport" name="departureAirport" type="text">
            </fieldset>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-2">
            <fieldset class="form-group">
              <label>到达机场</label>
              <input class="form-control" id="arrivalAirport" name="arrivalAirport" type="text">
            </fieldset>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-2">
            <fieldset class="form-group">
              <label>出发时间</label>
              <input class="form-control" id="departureTimeDp" name="departureTimeDp" type="datetime-local">
              <input type="hidden" id="departureTime" name="departureTime" value="" />
            </fieldset>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-2">
            <fieldset class="form-group">
              <label>到达时间</label>
              <input class="form-control" id="arrivalTimeDp" name="arrivalTimeDp" type="datetime-local">
              <input type="hidden" id="arrivalTime" name="arrivalTime" value="" />
            </fieldset>
          </div>
        </div>
        
        <button type="button" class="btn btn-outline-primary" style="" onclick="checkSubmit();">提交</button>
        </form>
    </div>
    </div>
    </div>
    <!-- /.content --> 
  </div>
  <script>
  	function checkSubmit(){
  		let flightNumber = $("#flightNumber").val();
  		let flightCompany = $("#flightCompany").val();
  		let flightModel = $("#flightModel").val();
  		let price = $("#price").val();
  		let departurePlace = $("#departurePlace").val();
  		let arrivalPlace = $("#arrivalPlace").val();
  		let departureAirport = $("#departureAirport").val();
  		let arrivalAirport = $("#arrivalAirport").val();
  		let departureTimeStr = $("#departureTimeDp").val();
  		let arrivalTimeStr = $("#arrivalTimeDp").val();
  		
  		if(flightNumber==null || flightNumber==""){
  			alertMsg("航班号不能为空");
  			return;
  		}
  		if(flightCompany==null || flightCompany==""){
  			alertMsg("航班公司不能为空");
  			return;
  		}
  		if(flightModel==null || flightModel==""){
  			alertMsg("机型不能为空");
  			return;
  		}
  		if(price==null || price==""){
  			alertMsg("票价不能为空");
  			return;
  		}
  		if(isNaN(price)){
  			alertMsg("票价请输入数字");
  			return;
  		}
  		if(departurePlace==null || departurePlace==""){
  			alertMsg("出发地不能为空");
  			return;
  		}
  		if(arrivalPlace==null || arrivalPlace==""){
  			alertMsg("到达地不能为空");
  			return;
  		}
  		if(departurePlace==arrivalPlace){
  			alertMsg("出发地不能与到达地相同");
  			return;
  		}
  		if(departureAirport==null || departureAirport==""){
  			alertMsg("出发机场不能为空");
  			return;
  		}
  		if(arrivalAirport==null || arrivalAirport==""){
  			alertMsg("到达机场不能为空");
  			return;
  		}
  		if(departureTimeStr==null || departureTimeStr==""){
  			alertMsg("出发时间不能为空");
  			return;
  		}
  		if(arrivalTimeStr==null || arrivalTimeStr==""){
  			alertMsg("到达时间不能为空");
  			return;
  		}
  		
  		departureTimeStr = departureTimeStr.replace("T"," ");
  		arrivalTimeStr = arrivalTimeStr.replace("T"," ");
  		$("#departureTime").val(departureTimeStr);
  		$("#arrivalTime").val(arrivalTimeStr);
  		let departureTime = new Date(departureTimeStr.replace("-", "/").replace("-", "/"));
  		let arrivalTime = new Date(arrivalTimeStr.replace("-", "/").replace("-", "/"));
  		let nowTime = new Date();
  		
  		if(departureTime >= arrivalTime){
  			alertMsg("到达时间必须大于出发时间");
  			return;
  		}
  		if(nowTime >= departureTime){
  			alertMsg("出发时间必须大于当前时间");
  			return;
  		}
  		if(nowTime >= arrivalTime){
  			alertMsg("到达时间必须大于当前时间");
  			return;
  		}
  		
  		$("#submitForm").submit();
  	}
  </script>
<#include "../footer.ftl">
</html>